<?php
/*
 +----------------------------------------------------------------------
 + Title        : CrmApiLog 控制器
 + Author       : Randy_chen
 + Version      : V1.0.0.1
 + Initial-Time : 2019/8/19 11:54
 + Last-time    : 2019/8/19 11:54+ 86187
 + Desc         : CrmApiLog
 +----------------------------------------------------------------------
*/


namespace app\admin\controller;


use app\common\lib\Where;
use library\Controller;

/**
 * 对外接口日志
 * Class CrmApiLog
 *
 * @package app\admin\controller
 */
class ApiLog extends Controller
{
    protected $table = 'api_log';

    /**
     * 对外接口日志管理
     *
     * @auth true
     * @menu true
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $this->title = '接口日志管理';
        if ($this->request->isPost()) {
            $model = new \app\common\model\ApiLog();
            $res = $model->equal('url,channel_id,ip')->dateBetween('create_time')->order('id desc')->_paginate();
            $this->success('查询成功!', $res);
            exit;
        } else {
            $this->applyCsrfToken();
            return $this->fetch();
        }
    }

    /**
     * CRM接口日志详情
     *
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException

     * @auth true
     * @menu true
     */
    public function detail(){
        $id = $this->request->param('id');
        $info = db($this->table)->find($id);
        $this->assign('info' , $info);
        return $this->fetch();
    }
}